package com.ihai.spring.boot.sample.distributed.counter;

import com.ihai.spring.boot.sample.distributed.counter.listener.NodeChangeEvent;
import com.ihai.spring.boot.sample.distributed.counter.manager.CounterManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.List;

/**
 * DESC
 *
 * @author 张驰
 * @date 2019/12/23
 */
@SpringBootApplication
public class DistributedCounterApplication {
    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(DistributedCounterApplication.class, args);
        CounterManager.init(true);
        List<String> nodes = new ArrayList<>();
        nodes.add("127.0.0.1:61213");
        nodes.add("127.0.0.1:61212");
        String current = "127.0.0.1:61212";
        NodeChangeEvent nodeChangeEvent = new NodeChangeEvent(new Object(),nodes,current);
        applicationContext.publishEvent(nodeChangeEvent);
    }
}
